package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Comparators;
import java.util.function.Function;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;

import array.EMp;

public class TestSoringCOllection {
	public static void main(String[] args) {
		
		ArrayList<EMp> empList = new ArrayList<EMp>();
		empList.add(new EMp("f", "d", 2));
		empList.add(new EMp("f", "b", 1));
		empList.add(new EMp("e", "f", 3));
		System.out.println(empList);
		Collections.sort(empList);
		System.out.println(empList);
		
		
		ArrayList<Integer> arrayList = new ArrayList<Integer>();
		arrayList.add(2);
		arrayList.add(1);
		arrayList.add(3);
		System.out.println(arrayList);
		
		Collections.sort(arrayList);
		System.out.println(arrayList);
		
		Collections.sort(arrayList, new DescSort());
		System.out.println(arrayList);
		
	
//		"2"   "1"     5      0 4 -1
//		 1 2   5      0   -1 4
//		1 2 0 4 -1
//		0 1 2 
//		
		// "-1" "0" "2"
		
		
	
		
	
	}
	
	static class 	DescSort implements Comparator<Integer>
	{

		@Override
		public int compare(Integer o1, Integer o2) {
//			
//			if(o1>o2)
//			{
//				return -1;
//			}else if (o1<o2)
//			{
//				return 1;
//			}
//			else
//			{
//				return 0;
//			}
			return o2-2*o1;
		}

		@Override
		public Comparator<Integer> reverseOrder() {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Comparator<Integer> thenComparing(
				Comparator<? super Integer> other) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public <U extends Comparable<? super U>> Comparator<Integer> thenComparing(
				Function<? super Integer, ? extends U> keyExtractor) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Comparator<Integer> thenComparing(
				ToIntFunction<? super Integer> keyExtractor) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Comparator<Integer> thenComparing(
				ToLongFunction<? super Integer> keyExtractor) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public Comparator<Integer> thenComparing(
				ToDoubleFunction<? super Integer> keyExtractor) {
			// TODO Auto-generated method stub
			return null;
		}

		
	}
}
